﻿using MediatR;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IRepository;
using S.EarTag.Read.API.Application.MediatorCommand.ProductionGradingCommand;

namespace S.EarTag.Read.API.Application.MediatorCommandHandler.ProductionGradingCommandHandler
{
    public class ProductionGradingByIdCommandHandler : IRequestHandler<ProductionGradingByIdCommand, ProductionGrading>
    {
        private readonly IProductionGradingRepository _productionGradingRepository;
        public ProductionGradingByIdCommandHandler(IProductionGradingRepository productionGradingRepository)
        {
            _productionGradingRepository = productionGradingRepository;
        }
        /// <summary>
        /// 根据耳号进行查询实现反填功能
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ProductionGrading> Handle(ProductionGradingByIdCommand request, CancellationToken cancellationToken)
        {
            return await _productionGradingRepository.GetByIdRankEarTag(request.RankEarTag);
        }
    }
}
